/**
 * Created by Administrator on 2018/10/28.
 */

function getPageHTML(data) {
    console.log(data);
    var $main = $('.goodsDetail-main');
    if(data.imageUrl){
        $main.find('.top-pic img').attr('src',data.imageUrl);
    }
    $main.find('.goods-title').text(data.name);
    $main.find('.goods-price').text('￥'+data.price);
    $main.find('.goods-address .address').text(data.address);
    $main.find('.goods-tel .tel').text(data.mobile);
    $main.find('.goods-desc p').text(data.introduction);
}

function initPageClick() {
    var swiper = new Swiper('.swiper-container', {
        pagination: {
            el: '.swiper-pagination',
        },
    });

    $('.goods-item').on('click', function () {
        var $this = $(this);
        var itemId = $this.attr('data-id');
        window.location.href = 'goodsDetail.html?id=' + itemId;
    })
}

$(function () {
    var url = window.location.search;
   if(url.length>0&&url.split('=')[1]){
       ajax({
           url: 'app/ad/getADDetail',
           data: {
               id:url.split('=')[1]
           },
           success: function (d) {
               getPageHTML(d);
               initPageClick();

           },
           fail: function () {
               _alert('修改密码失败');
           }
       })
   }

});